package com.qdhhxy.controller;

import com.qdhhxy.entity.CarEntity;
import com.qdhhxy.service.ICarservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class CarController {
    @Autowired
    private ICarservice carservice;

    @RequestMapping("/insertCar")
    public String insertCar(CarEntity carEntity) {
        System.out.println("controller"+carEntity.getCarNum()+carEntity.getBrand()+carEntity.getProduceTime());
        carservice.insertCar(carEntity);
        return "insert car";
    }
    @RequestMapping("/selectCarById")
    public CarEntity selectCarById(int id) {
        CarEntity car = carservice.selectCarById(id);
        System.out.println(car.getCarNum());
        return car;
    }
    @RequestMapping("/selectCarByStuId")
    public List<CarEntity> selectCarByStuId(int stuId) {
        List<CarEntity> cars = carservice.selectCarByStuId(stuId);
        return cars;
    }
}

